package com.autism_lin.myapp;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import android.os.Bundle;
import com.google.android.material.bottomnavigation.BottomNavigationView;

public class MainActivity extends AppCompatActivity {
//    private static final String TAG ="" ;
    private BottomNavigationView bottomNavigationView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

    bottomNavigationView = findViewById(R.id.nav);
    bottomNavigationView.setOnNavigationItemSelectedListener( item ->{
        FragmentManager fragmentManager = getSupportFragmentManager();

        switch (item.getItemId()){
            case R.id.nav_menu0:
                fragmentManager.beginTransaction()
                        .replace(R.id.fragmentContainerView,Fragment_menu0.class,null)
                        .setReorderingAllowed(true)
                        .commit();
//                Log.d(TAG,"");
                return true;
            case R.id.nav_menu1:
                fragmentManager.beginTransaction()
                        .replace(R.id.fragmentContainerView,Fragment_menu1.class,null)
                        .setReorderingAllowed(true)
                        .commit();
//                Log.d(TAG,"");
                return true;
            case R.id.nav_menu2:
                fragmentManager.beginTransaction()
                        .replace(R.id.fragmentContainerView,Fragment_menu2.class,null)
                        .setReorderingAllowed(true)
                        .commit();
//                Log.d(TAG,"");
                return true;
            case R.id.nav_menu3:
                fragmentManager.beginTransaction()
                        .replace(R.id.fragmentContainerView,Fragment_menu3.class,null)
                        .setReorderingAllowed(true)
                        .commit();
//                Log.d(TAG,"");
                return true;
            default:
                return false;
        }
    } );
    }
}